package com.example.snackfood.dao;

import com.example.snackfood.entity.Carts;
import com.example.snackfood.entity.Products;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: snackFood
 * @description:
 * @author: lydms
 * @create: 2023-11-24 22:57
 **/


@Component
public class SnackFoodCartsDao {

    @Resource
    private MongoTemplate mongoTemplate;

    public void save(Carts carts) {
        mongoTemplate.save(carts);
    }

    public void delete(Query query) {
        mongoTemplate.remove(query,Carts.class);
    }


    public void update(Query query, Update update) {
        mongoTemplate.updateMulti(query,update,Carts.class);
    }

    public Carts get(Query query) {
        return mongoTemplate.findOne(query,Carts.class);
    }

}
